package com.dyz.swordFingerOffer;

/**
 * @author: daiyizheng
 * @date: 2021/5/30 15:52
 * @description:
 */
public class Power16 {
    public double Power(double base, int exponent) {
        double ans = 1.0;
        if (exponent >= 0) {
            for (int i = 1; i <= exponent; i++) {
                ans *= base;
            }
        } else {
            for (int i = 1; i <= -exponent; i++) {
                ans *= 1.0 / base;
            }

        }

        return ans;
    }
}
